package com.aerfafish.spider.utils;

import us.codecraft.webmagic.Request;

import java.util.Map;

/**
 * @author aerfafish
 * @date 2021/4/19 10:45 上午
 */
public class RequestUtil {

    public static Request urlToRequest(String url) {
        Request request = new Request(url);
        request.addHeader("Referer", "http://fundf10.eastmoney.com");
        return request;
    }

    public static Request urlToRequest(String url, String referer) {
        Request request = new Request(url);
        request.addHeader("Referer", referer);
        return request;
    }

    public static Request urlToRequest(String url, Map<String, String> header) {
        Request request = new Request(url);
        for (Map.Entry<String, String> entry : header.entrySet()) {
            request.addHeader(entry.getKey(), entry.getValue());
        }
        return request;
    }


}
